
package com.yuan.view;

import com.yuan.graduate.LoginActivity;
import com.yuan.graduate.R;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

/**
 * 引导页最后一页 需要用户协议
 * 
 * @author YUAN
 */
public class GuideLastPages {
    // 变量
    private Context mContext = null;
    private View mView = null;
    public CheckBox mCheck = null;
    private TextView mSee_agree = null;
    private Button mEnsure = null;

    // 构造函数,初始化
    public GuideLastPages(Context mContext) {
        this.mContext = mContext;
        if (this.mContext != null) {
            mView = LayoutInflater.from(this.mContext).inflate(R.layout.user_statement, null);
            initViews();
        }
    }

    /**
     * 初始化控件
     */
    private void initViews() {
        mSee_agree = (TextView) mView.findViewById(R.id.see_agree);
        mSee_agree.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
        mCheck = (CheckBox) mView.findViewById(R.id.checked);
        mEnsure = (Button) mView.findViewById(R.id.ensure);

        // 设置控件监听
        setListener();
    }

    /**
     * 获取跳转按钮
     */
    public Button getmEnsure() {
        return mEnsure;
    }

    /**
     * 获取View
     */
    public View getmView() {
        return mView;
    }

    /**
     * 设置监听
     **/
    private void setListener() {
        // 设置checkbox点击事件
        mCheck.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        // 查看用于协议
        mSee_agree.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startOtherActivity();
            }
        });
        mEnsure.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startLoginActivity();
            }

        });
    }

    private void startLoginActivity() {
        // TODO Auto-generated method stub
        mContext.startActivity(new Intent(mContext, LoginActivity.class));
    }

    /**
     * 跳转协议页
     */
    private void startOtherActivity() {
        // if (mContext != null)
        // mContext.startActivity(new Intent(mContext,
        // UserExpPreferenceActivity.class));
    }

    /**
     * 设置是否选中
     */
    public void setIsChecked(boolean isJoin) {
        if (mCheck != null)
            mCheck.setChecked(isJoin);
    }

    public void onDestroy() {
        // TODO Auto-generated method stub
        mContext = null;
        mView = null;
        mCheck = null;
        mSee_agree = null;
        mEnsure = null;

    }
}
